/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package sampledata.barratt;

import barratt.BarrattModelData;
import barratt.cef.pui.pob.Builders;
import cef.pui.pob.Builder;
import cef.pui.pob.BuilderException;
import commons.nb.data.DNData;

import java.util.Properties;

/**
 * @since 1.0.0
 * @version 1.0.0
 * @author Susanta Tewari
 * @history Created on May 23, 2012.
 */
public final class BarrattModelDataDNDataFileBased extends DNData<BarrattModelData> {

    /** Field description */
    private final Builder<BarrattModelData> builder;

    /**
     * Initializes description properties and creates the builder.A builder is created ({@link Builders#getMoneyBudgetBuilderFileBased(java.util.Properties)})
     * based on the supplied file URL.
     *
     * @param displayName display name
     * @param shortDescription short description
     * @param URL file URL; <a href="tracker/cef/pui/pob/doc-files/MoneyBudget.xml.txt">file
     * </a>, must accompany the <a href="tracker/cef/pui/pob/doc-files/Budget.xsd.txt">schema</a>
     */
    public BarrattModelDataDNDataFileBased(final String displayName, final String shortDescription,
            final String URL) {

        super("BarrattModelData");

        setDisplayName(displayName);
        setShortDescription(shortDescription);


        // builder
        final Properties props = new Properties();

        props.setProperty("barratt.builder.BarrattModelData.url", "barratt:xml//" + URL);

        builder = Builders.of_BarratModelData_File(props, null);
    }

    /**
     * Method description
     *
     *
     * @return
     *
     * @throws cef.pui.pob.BuilderException
     */
    @Override
    public Builder<BarrattModelData> getBuilder() throws BuilderException {
        return builder;
    }

    /**
     * Method description
     *
     *
     * @return
     */
    @Override
    public Class<BarrattModelData> getBuilderValueType() {
        return BarrattModelData.class;
    }
}
